﻿<UserControl x:Class="DaxStudio.UI.Views.RibbonView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform"
             xmlns:local="clr-namespace:DaxStudio.UI.Utils" 
             xmlns:conv="clr-namespace:DaxStudio.UI.Converters"
             xmlns:beh="clr-namespace:DaxStudio.UI.Behaviours"
             mc:Ignorable="d" 
             d:DesignHeight="137" d:DesignWidth="654">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary  Source="pack://application:,,,/DaxStudio.UI;Component/Resources/IconResourceDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>
        
        
<!--
        <conv:ResourceLookupConverter x:Key="OutputIcons">
            <ResourceDictionary>
                <BitmapImage x:Key="Grid" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-table@96ppi.png"/>
                <BitmapImage x:Key="Timer" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-timer@96ppi.png"/>
                <BitmapImage x:Key="Static" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-excelstatic@96ppi.png"/>
                <BitmapImage x:Key="Linked" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-excellinked@96ppi.png"/>
            </ResourceDictionary>
        </conv:ResourceLookupConverter>
-->
        <conv:ResourceLookupConverter x:Key="TraceIcons">
            <ResourceDictionary>
                <BitmapImage x:Key="Query Plan" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-plan@17px.png"/>
                <BitmapImage x:Key="Server Timings" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-timings@17px.png"/>
            </ResourceDictionary>
        </conv:ResourceLookupConverter>

        <conv:ResourceLookupConverter x:Key="TraceIconsLarger">
            <ResourceDictionary>
                <BitmapImage x:Key="Query Plan" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-plan@96ppi.png"/>
                <BitmapImage x:Key="Server Timings" UriSource="pack://application:,,,/DaxStudio.UI;component/images/icon-timings@96ppi.png"/>
            </ResourceDictionary>
        </conv:ResourceLookupConverter>

        
        <!--<SolidColorBrush x:Key="DaxStudioBackgroundBrush" Color="#FF449ADE"></SolidColorBrush>
        <SolidColorBrush x:Key="BackstageBackgroundBrush" Color="#FF24B010"></SolidColorBrush>-->
        
        <DataTemplate x:Key="ResultsTargetTemplate">
            <Border Tag="Excel"
                        BorderThickness="4"
                        BorderBrush="Transparent">
                <StackPanel>
                    <Image VerticalAlignment="Top"
                        Source="{Binding Name, Converter={StaticResource OutputIcons}}"
                        Stretch="None" />
                    <TextBlock Text="{Binding Name}"
                        VerticalAlignment="Bottom"
                        HorizontalAlignment="Center" />
                </StackPanel>
            </Border>
        </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
            
        <Fluent:Ribbon Height="Auto" CanCustomizeQuickAccessToolBar="False" CanCustomizeQuickAccessToolBarItems="False">    
        <Fluent:Ribbon.Resources>

            <DataTemplate x:Key="TraceWatcherTemplate">
                <Fluent:ToggleButton Header="{Binding Title}" IsChecked="{Binding IsChecked, Mode=TwoWay}" 
                                     SizeDefinition="Large" 
                                     ClickMode="Press" Width="Auto" 
                                     Icon="{Binding Title, Converter={StaticResource TraceIcons}}"
                                     LargeIcon="{Binding Title, Converter={StaticResource TraceIconsLarger}}"
                                     IsEnabled="{Binding IsEnabled}">
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="{Binding Title}" Text="{Binding ToolTipText}" />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>
                
                
            </DataTemplate>

            <Style x:Key="TabButton" TargetType="Fluent:Button">
                <Setter Property="Foreground" Value="White"></Setter>
            </Style>
            <!--
            <Style x:Key="BackstageTabButton">
                <Setter Property="Margin" Value="50"></Setter>
            </Style>
            -->
        </Fluent:Ribbon.Resources>

        <!--Backstage-->
        <Fluent:Ribbon.Menu>
            
            <Fluent:Backstage >
                <Fluent:BackstageTabControl>

                    <!-- File New -->
                    <Fluent:Button Header="New" 
                                   x:Name="NewQuery" 
                                   HorizontalContentAlignment="Left" 
                                   Foreground="White"
                                   Icon="{StaticResource NewIconSmall}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="NewQuery">

                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Fluent:Button>

                    <Fluent:BackstageTabItem Header="Open"  >
                        
                        <!-- Right-side content here -->
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="200" />
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <StackPanel HorizontalAlignment="Left" Grid.Column="0" Margin="10px">
                                <Border>
                                    <Fluent:Button Style="{DynamicResource ButtonBackstageStyle}" 
                                           BorderBrush="DimGray"  
                                           BorderThickness="1" 
                                           LargeIcon="{StaticResource BrowseIconLarger}"
                                           Header="Browse"
                                           SizeDefinition="Large"
                                           Height="100" Width="100" Foreground="Black">
                                           
                                        <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="Open">
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Fluent:Button>
                                </Border>

                            </StackPanel>
                            <StackPanel HorizontalAlignment="Left" Margin="20,0" Grid.Column="1">
                                <Label FontSize="14" Foreground="DimGray" FontWeight="Bold">Select a Document</Label>
                            </StackPanel>
                        </Grid> 
                    </Fluent:BackstageTabItem>
                    <!--<Fluent:Button x:Name="NewQuery" Header="New Query"></Fluent:Button>-->

                    <Fluent:Button Header="Save" Foreground="White" HorizontalContentAlignment="Left" Icon="{StaticResource SaveIcon}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="Save">

                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>

                    </Fluent:Button>
                    <Fluent:Button Name="btnSaveAs" Header="Save As" Foreground="White">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SaveAs">

                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>

                    </Fluent:Button>

                    <Fluent:Button Name="btnExit" Header="Exit" Foreground="White">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="Exit">

                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Fluent:Button>
                </Fluent:BackstageTabControl>
            </Fluent:Backstage>
        </Fluent:Ribbon.Menu>

        <Fluent:Ribbon.QuickAccessItems>
<!--
            <Fluent:QuickAccessMenuItem Header="New" 
                                        IsChecked="True"
                                        Target="{Binding ElementName=NewQueryQat}"
                                        Command="{Binding NewQuery}"
                                        Icon="{StaticResource NewIconSmall}"
                                        IsDefinitive="True"
                                        >
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cal:ActionMessage MethodName="NewQuery">

                        </cal:ActionMessage>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Fluent:QuickAccessMenuItem>
            
            <Fluent:QuickAccessMenuItem Target="{Binding ElementName=saveButton}" 
                                        Command="{Binding Save}"
                                        Icon="{StaticResource SaveIcon}"
                                        IsChecked="True"
                                        IsDefinitive="True">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cal:ActionMessage MethodName="Save">

                        </cal:ActionMessage>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Fluent:QuickAccessMenuItem>
    -->        
            </Fluent:Ribbon.QuickAccessItems>

        <!-- Home Tabs-->
        <Fluent:RibbonTabItem Header="Home">
            <Fluent:RibbonGroupBox Header="Query" Margin="4,0">
                <Fluent:Button Name="RunQuery"
                               Header="Run"
                               cal:Message.Attach="[Event Click] = [Action RunQuery()]"
                               LargeIcon="{StaticResource PlayIconLarger}"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Run Query (F5)"
                                          Text="Executes the query and sends the results to the selected output"
                                          DisableReason="{Binding RunQueryDisableReason}"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <Fluent:Button Name="CancelQuery"
                               Header="Cancel"
                               cal:Message.Attach="[Event Click] = [Action CancelQuery()]"
                               LargeIcon="{StaticResource CancelIconLarger}"
                               Margin="4,0"
                               >
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Cancel Query (Esc)"
                                          Text="Sends a cancel command to a currently running query"
                                          DisableReason="No Query is currently running"
                                          ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <Fluent:Button Name="ClearCache"
                               Header="Clear Cache"
                               cal:Message.Attach="[Event Click] = [Action ClearCache()]"
                               LargeIcon="{StaticResource ClearCacheIconLarger}"
                               Margin="4,0"
                               >
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Clear Cache"
                                          Text="Clears the cache for the current database"
                                          DisableReason="{Binding ClearCacheDisableReason}"
                                          ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <!-- Output Targets -->
                <Fluent:DropDownButton Name="Output"
                                           Header="Output"
                                           LargeIcon="{Binding Path=SelectedTarget.Name,Converter={StaticResource OutputIcons}}"
                                           IsEnabled="True"
                                           VerticalAlignment="Top"  Margin="4,0">

                    <Fluent:Gallery 
                        SelectedFilter="{Binding ElementName=galleryFilterAll3}"
                        GroupBy="Group"
                        x:Name="OutputGallery"
                        MinItemsInRow="1"
                        MaxItemsInRow="4"
                        Orientation="Horizontal"
                        ItemWidth="80"
                        ItemHeight="80"
                        ItemsSource="{Binding ResultsTargets}"
                        SelectedItem="{Binding SelectedTarget}"
                        ItemTemplate="{DynamicResource ResultsTargetTemplate}">

                        <Fluent:Gallery.Filters>
                            <Fluent:GalleryGroupFilter Title="All"
                                                           Groups="Standard,Excel,Undefined"
                                                           x:Name="galleryFilterAll3" />
                            <Fluent:GalleryGroupFilter Title="Standard"
                                                           Groups="Standard" />
                            <Fluent:GalleryGroupFilter Title="Excel"
                                                           Groups="Excel" />
                        </Fluent:Gallery.Filters>

                    </Fluent:Gallery>
                    <Fluent:DropDownButton.ToolTip>
                        <Fluent:ScreenTip Title="Output Target" Text="This specifies where the query results get sent" Width="190" />
                    </Fluent:DropDownButton.ToolTip>
                </Fluent:DropDownButton>
            </Fluent:RibbonGroupBox>
            
            
            

            <Fluent:RibbonGroupBox Header="Edit" Margin="4,0">
                <Fluent:ToggleButton x:Name="Cut"
                                Fluent:KeyTip.Keys="X"
                                Header="Cut"
                                Icon="{StaticResource CutIconLarger}"
                                SizeDefinition="Middle,Small"
                                Command="Cut"
                                FocusManager.IsFocusScope="True"
                                >
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="Cut (Ctrl+X)"
                                          Text="Cut the contents to the Clipboard."
                                          DisableReason="Nothing is currently selected"
                                          Width="190" />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>
                <Fluent:ToggleButton x:Name="Copy"
                               Fluent:KeyTip.Keys="C"
                               Header="Copy"
                               Icon="{StaticResource CopyIconLarger}"
                               SizeDefinition="Middle,Small"
                               Command="ApplicationCommands.Copy"
                               FocusManager.IsFocusScope="True"
                               >
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="Copy (Ctrl+C)"
                                              Text="Copy the contents to the Clipboard."
                                              DisableReason="Nothing is currently selected"
                                              Width="190" />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>

                <Fluent:Button x:Name="Paste"
                               Fluent:KeyTip.Keys="V"
                               Header="Paste"
                               Icon="{StaticResource PasteIconLarger}"
                               SizeDefinition="Middle,Small"
                               Command="Paste"
                               IsEnabled="True"
                               FocusManager.IsFocusScope="True"
                               >
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Paste (Ctrl+V)"
                                              Text="Paste the contents from the Clipboard."
                                              DisableReason="The currently selected control does not support Paste or the clipboard is empty"
                                              Width="190" />
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <Fluent:Button x:Name="undoButton"
                               Header="Undo"
                               Fluent:KeyTip.Keys="Z"
                               cal:Message.Attach="[Event Click] = [Action Undo()]"
                               Icon="{StaticResource UndoIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Undo (Ctrl+Z)"
                                          Text="Undoes previous actions"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <Fluent:Button x:Name="redoButton"
                               Header="Redo"
                               Fluent:KeyTip.Keys="Y"
                               cal:Message.Attach="[Event Click] = [Action Redo()]"
                               Icon="{StaticResource RedoIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Redo (Ctrl+Y)"
                                          Text="Re-does changes that were previously undone"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>

                <Fluent:Button x:Name="saveButton"
                               Header="Save"
                               Fluent:KeyTip.Keys="S"
                               cal:Message.Attach="[Event Click] = [Action Save()]"
                               Icon="{StaticResource CommentIcon}"
                               SizeDefinition="Middle,Small"
                               Visibility="Hidden"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Save (Ctrl+S)"
                                          Text="Saves the current document"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>


            </Fluent:RibbonGroupBox>

            <Fluent:RibbonGroupBox Header="Format" Margin="4,0">
                <Fluent:Button Name="FormatQuery"
                               Header="Format Query"
                               cal:Message.Attach="[Event Click] = [Action FormatQuery()]"
                               LargeIcon="{StaticResource DaxFormatterIcon}" 
                               Margin="0,0,10,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Format Query"
                                          Text="Uses DaxFormatter.com to provide a nicely formatted query and highlight syntax errors"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                

                <Fluent:Button Name="ToUpper"
                               Header="To Upper"
                               cal:Message.Attach="[Event Click] = [Action ToUpper()]"
                               Icon="{StaticResource ToUpperIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="To Upper (Ctrl+Shift U)"
                                          Text="Converts the selected text to Uppercase"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <Fluent:Button Name="ToLower"
                               Header="To Lower"
                               cal:Message.Attach="[Event Click] = [Action ToLower()]"
                               Icon="{StaticResource ToLowerIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="To Lower (Ctrl+Shift L)"
                                          Text="Converts the selected text to Lowercase"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                
                <Fluent:Button Visibility="Hidden" Width="1"></Fluent:Button>
                
                 <Fluent:Button Name="CommentSelection"
                               Header="Comment"
                               cal:Message.Attach="[Event Click] = [Action CommentSelection()]"
                               Icon="{StaticResource CommentIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                        <Fluent:Button.ToolTip>
                            <Fluent:ScreenTip Title="Comment (Ctrl+Alt C)"
                                          Text="Comments the selected lines"
                                           ></Fluent:ScreenTip>
                        </Fluent:Button.ToolTip>
                    </Fluent:Button>
                    <Fluent:Button Name="UncommentSelection"
                               Header="Uncomment"
                               cal:Message.Attach="[Event Click] = [Action UncommentSelection()]"
                               Icon="{StaticResource UncommentIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                        <Fluent:Button.ToolTip>
                            <Fluent:ScreenTip Title="Uncomment (Ctrl+Alt U)"
                                          Text="Uncomments the selected lines"
                                           ></Fluent:ScreenTip>
                        </Fluent:Button.ToolTip>
                    </Fluent:Button>
                <Fluent:Button Name="MergeParameters"
                               Header="Merge XML"
                               cal:Message.Attach="[Event Click] = [Action MergeParameters()]"
                               Icon="{StaticResource MergeIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Merge Parameters"
                                          Text="Merges Parameter XML block from a profiler trace"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                
            </Fluent:RibbonGroupBox>
  
            <Fluent:RibbonGroupBox Header="Find" Margin="4,0">
                <Fluent:Button Header="Find" 
                               Command="Find"
                               Icon="{StaticResource FindIconSmall}"
                               SizeDefinition="Middle,Small"
                               Fluent:KeyTip.Keys="F"
                               FocusManager.IsFocusScope="True">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Find" Text="Find text within the current query" Width ="190"/>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <!-- cal:Message.Attach="[Event Click] = [Action Find()]" -->
                <Fluent:Button Header="Replace" 
                               Command="Replace"
                               Icon="{StaticResource ReplaceIconSmall}"
                               SizeDefinition="Middle,Small"
                               Fluent:KeyTip.Keys="H"
                               FocusManager.IsFocusScope="True">
                <!-- cal:Message.Attach="[Event Click] = [Action Replace()]" -->
                <Fluent:Button.ToolTip>
                    <Fluent:ScreenTip Title="Find" Text="Replace text within the current query" Width ="190"/>
                </Fluent:Button.ToolTip>
                </Fluent:Button>

               
            </Fluent:RibbonGroupBox>
            
            
            
          
            
            <Fluent:RibbonGroupBox Header="Traces" ItemsSource="{Binding TraceWatchers}"
                                   ItemTemplate="{DynamicResource TraceWatcherTemplate}">
                
            </Fluent:RibbonGroupBox>
            <Fluent:RibbonGroupBox Header="Server Timings" Margin="4,0" IsEnabled="{Binding ServerTimingsIsChecked}">
                <Fluent:ToggleButton x:Name="TimingsScan" IsChecked="{Binding ServerTimingDetails.ShowScan, Mode=TwoWay}" 
                                IsEnabled="{Binding ServerTimingsChecked}"
                                Header="Scan"
                                Icon="{StaticResource TimerIcon}"
                                SizeDefinition="Middle,Small"
                                >
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="Scan"
                                          Text="Show scan timings"
                                           />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>
                <Fluent:ToggleButton x:Name="TimingsCache" IsChecked="{Binding ServerTimingDetails.ShowCache, Mode=TwoWay}" 
                                IsEnabled="{Binding ServerTimingsChecked}"
                                Header="Cache" 
                                Icon="{StaticResource TimingsCache}"
                                SizeDefinition="Middle,Small"
                                >
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="Cache"
                                          Text="Show cache timings"
                                           />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>
                <Fluent:ToggleButton x:Name="TimingsInternal" IsChecked="{Binding ServerTimingDetails.ShowInternal, Mode=TwoWay}" 
                                IsEnabled="{Binding ServerTimingsChecked}"
                                Header="Internal"
                                Icon="{StaticResource TimingsInternal}"
                                SizeDefinition="Middle,Small"
                                >
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="Internal"
                                          Text="Show internal timings"
                                           />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>
                
                
                
                <Fluent:ToggleButton x:Name="TimingsRightPane" 
                                IsChecked="{Binding ServerTimingDetails.LayoutRight, Mode=TwoWay}" 
                                IsEnabled="{Binding ServerTimingsChecked}"
                                Header="Right Layout"
                                Icon="{StaticResource RightPane}"
                                SizeDefinition="Middle,Small"
                                >
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="Right Layout"
                                          Text="Show Preview Pane on the right"
                                           />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>

                <Fluent:ToggleButton x:Name="TimingsBottomPane"
                                IsChecked="{Binding ServerTimingDetails.LayoutBottom, Mode=TwoWay}" 
                                IsEnabled="{Binding ServerTimingsChecked}"
                                Header="Bottom Layout"
                                Icon="{StaticResource BottomPane}"
                                SizeDefinition="Middle,Small"
                                >
                    <Fluent:ToggleButton.ToolTip>
                        <Fluent:ScreenTip Title="Bottom Layout"
                                          Text="Show Preview Pane on bottom"
                                           />
                    </Fluent:ToggleButton.ToolTip>
                </Fluent:ToggleButton>
            </Fluent:RibbonGroupBox>

            <Fluent:RibbonGroupBox Header="Connection" Margin="2,0">
                <Fluent:Button x:Name="Connect" 
                               Header="Connect"
                               LargeIcon="{StaticResource ConnectIconLarger}" 
                               Margin="4,0"
                               cal:Message.Attach="[Event Click] = [Action Connect()]" >
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Connect" Text="Changes the connection for the current query" Width="190"/>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                                
                
               
                <Fluent:Button Name="RefreshMetadata"
                               Header="Refresh Metadata"
                               cal:Message.Attach="[Event Click] = [Action RefreshMetadata()]"
                               Icon="{StaticResource RefreshIcon}"
                               LargeIcon="{StaticResource RefreshIconLarger}"
                               Margin="4,0"
                               >
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Refresh Metadata"
                                          Text="Refreshes the table and column metadata for the current database"
                                          DisableReason="{Binding ClearCacheDisableReason}"
                                          ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
            </Fluent:RibbonGroupBox>
       
        
           
          
        </Fluent:RibbonTabItem>
            
        <!-- Help Tab -->
        <Fluent:RibbonTabItem Header="Help">
            <Fluent:RibbonGroupBox Header="Links" Margin="0,0,4,0">
                <Fluent:Button Name="helpDaxStudioWiki"
                               Header="DAX Studio Help"
                               cal:Message.Attach="[Event Click] = [Action LinkToDaxStudioWiki()]"
                               Icon="{StaticResource ExternalLinkIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="DAX Studio Help"
                                          Text="Links to the documentation on the DAX Studio website"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <Fluent:Button Name="hlpPowerPivotForum"
                               Header="Power Pivot Forum"
                               cal:Message.Attach="[Event Click] = [Action LinkToPowerPivotForum()]"
                               Icon="{StaticResource ExternalLinkIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Power Pivot Forum"
                                          Text="Link to the Power Pivot MSDN Forum"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
                <Fluent:Button Name="hlpSSASForum"
                               Header="Analysis Services Forum"
                               cal:Message.Attach="[Event Click] = [Action LinkToSsasForum()]"
                               Icon="{StaticResource ExternalLinkIcon}"
                               SizeDefinition="Middle,Small"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Analysis Services Forum"
                                          Text="Link to the Analysis Services MSDN Forum"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
            </Fluent:RibbonGroupBox>
            <Fluent:RibbonGroupBox Header="" Margin="0,0,4,0">
                <Fluent:Button Name="hlpAbout"
                               Header="About DaxStudio"
                               cal:Message.Attach="[Event Click] = [Action ShowHelpAbout()]"
                               Icon="{StaticResource InformationIcon}"
                               LargeIcon="{StaticResource InformationIcon}"
                               SizeDefinition="Large,Middle"
                               Margin="4,0">
                    <Fluent:Button.ToolTip>
                        <Fluent:ScreenTip Title="Help About"
                                          Text="Shows version information"
                                           ></Fluent:ScreenTip>
                    </Fluent:Button.ToolTip>
                </Fluent:Button>
            </Fluent:RibbonGroupBox>
            
                
            
        </Fluent:RibbonTabItem>

        <!-- ToMove Tab 
        <Fluent:RibbonTabItem Header="ToMove">
            <Fluent:RibbonGroupBox Header="Database" Margin="0,0,4,0">
                <TextBlock Text="Database:" Padding="0,6,0,0"/>
                <Fluent:ComboBox x:Name="Database" 
                                 SelectedItem="{Binding SelectedDatabase}"
                                 ItemsSource="{Binding Databases}"   
                                 MinWidth="160" 
                                 MaxWidth="250" 
                                 IsEditable="False"
                                 IsSynchronizedWithCurrentItem="True" 
                                 IsEnabled="{Binding CanSelectDatabase}" 
                                 Margin="0,8,8,0" ToolTip="{Binding SelectedDatabase}">
                    <Fluent:ComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{StaticResource DatabaseIcon}" Width="16" Height="16"></Image>
                                <TextBlock Text="{Binding}" Margin="4,0" ></TextBlock>
                            </StackPanel>
                        </DataTemplate>
                    </Fluent:ComboBox.ItemTemplate>
                </Fluent:ComboBox>
            </Fluent:RibbonGroupBox>
            <Fluent:RibbonGroupBox Header="Output" x:Name="OutputGroup" Visibility="{Binding OutputGroupIsVisible}" >
                <TextBlock Text="Worksheet:" Padding="0,6,0,0"/>
                <Fluent:ComboBox Name="cboOutputTo" 
                                 Text="&lt;Output Sheet&gt;" 
                                 MinWidth="120" MaxWidth="200" 
                                 IsEditable="False" 
                                 ItemsSource="{Binding Worksheets}" 
                                 SelectedItem="{Binding SelectedWorksheet}"
                                 Margin="0,8,8,0">

                </Fluent:ComboBox>
            </Fluent:RibbonGroupBox>
        </Fluent:RibbonTabItem>
-->


        <!-- Quick Access Targets -->
        <Fluent:RibbonTabItem Visibility="Collapsed">
            <Fluent:RibbonGroupBox x:Name="QuickAccessHiddenCommands">
            <Fluent:Button Header="New" 
                                   x:Name="NewQueryQat" 
                                   HorizontalContentAlignment="Left" 
                                   Foreground="White"
                                   Icon="{StaticResource NewIconSmall}">

                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cal:ActionMessage MethodName="NewQuery">

                        </cal:ActionMessage>
                    </i:EventTrigger>
                </i:Interaction.Triggers>

            </Fluent:Button>
            </Fluent:RibbonGroupBox>
        </Fluent:RibbonTabItem>
    </Fluent:Ribbon>

</UserControl>
